﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DK.Sort
{
    public class ShellSort : ISort
    {
        public void Sort(int[] array)
        {
            /*
             * 1.设置增量
             * 2.增量递减
             * 3.插入排序
             */

            for (int ger = (array.Length / 2); ger >= 1; ger /= 2)
            {
                for (int i = 0; i + ger < array.Length; i++)
                {
                    var index = i + ger;
                    for (int j = index - ger; j >= 0 && array[index] < array[j]; j -= ger)
                    {
                        ISort.Transfrom(array, index, j);
                        index -= ger;
                    }
                }
            }

        }
    }
}
